#import "TSHomeMsgCell.h"
#import "TSTaskModel.h"
#import "CircleView.h"
#define MESSAGE_CELL_GAP 5.f
#define TIME_LABEL_WIDTH 160.f
#define SECTION_LABEL_WIDTH (currentDeviceWidth-TIME_LABEL_WIDTH-STATUS_LABEL_WIDTH-2*MESSAGE_CELL_GAP-2*MARGIN_LEFT)
#define STATUS_LABEL_WIDTH 80.f
#define LEFT_MARGIN 65
#define DATA_LABEL_WIDTH 55
@implementation TSHomeMsgCell{
    UIView *badgeView;
    UILabel *numLable;
    
    UILabel *titleLabel;
    UILabel *descLabel;
    UILabel *dataLabel;
}

-(void)initUI{
    [self addTitleLable];
    [self addDescLabel];
    [self addDataLabel];
}

-(void)setTitle:(NSString *)title{
    if (titleLabel) {
        [titleLabel setText:title];
    }
}
-(void)setDesc:(NSString *)desc{
    if (descLabel) {
        [descLabel setText:desc];
    }
}
-(void)setDate:(NSString *)date{
    if (dataLabel) {
        [dataLabel setText:date];
    }
}

-(void)addTitleLable{
    titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(LEFT_MARGIN, 0, currentDeviceWidth-LEFT_MARGIN-DATA_LABEL_WIDTH, 25)];
    [titleLabel setTextColor:[UIColor blackColor]];
    titleLabel.font = FONT(14);
    [self addSubview:titleLabel];
 
}

-(void)addDescLabel{
    descLabel = [[UILabel alloc] initWithFrame:CGRectMake(LEFT_MARGIN, 25,  currentDeviceWidth-LEFT_MARGIN-DATA_LABEL_WIDTH, 10)];
    [descLabel setTextColor:RGB(190, 190, 190)];
    descLabel.font = FONT(10);
     [self addSubview:descLabel];
    
}

-(void)addDataLabel{
    dataLabel = [[UILabel alloc] initWithFrame:CGRectMake(currentDeviceWidth-DATA_LABEL_WIDTH, 10, DATA_LABEL_WIDTH, 10)];
    [dataLabel setTextColor:RGB(190, 190, 190)];
    dataLabel.font = FONT(10);
    [self addSubview:dataLabel];
}


-(void)setNum:(NSInteger)number
{
    if(number==0){
        if(badgeView){
            [badgeView removeFromSuperview];
        }
        return;
    }
    if(!badgeView&&number!=0){
        badgeView = [[CircleView alloc] initWithFrame:CGRectMake(40, 5, 14, 14)];
        [badgeView setBackgroundColor:[UIColor clearColor]];
        [self addSubview:badgeView];
        numLable = [[UILabel alloc] init];
        numLable.font = FONT(10);
        [numLable setTextColor:[UIColor whiteColor]];
        numLable.frame= CGRectMake(0, 0, 14, 14);
        numLable.textAlignment = UITextAlignmentCenter;
        [badgeView addSubview:numLable];
    }
    [numLable setText:[NSString stringWithFormat:@"%ld",(long)number]];
    
}

@end
